package lesson15Class;

class Car {
	String model;
	double maxSpeed;
	double currentSpeed;
	String color;
	int currentGear;
	int maxGear = 5;
	Person owner;
	double price;
	boolean isSportsCar;

	Car() {
		isSportsCar = false;
	}

	Car(String model) {
		this.model = model;
	}

	Car(String model, String color) {
		this(model);
		this.color = color;
	}

	Car(String model, boolean isSportCar, String color, double price, double maxSpeed)
	{
		this(model, color);
		this.isSportsCar = isSportCar;
		this.price = price;
		if (maxSpeed > 200) {
			if (isSportCar)
				this.maxSpeed = maxSpeed;
		} else {
			this.maxSpeed = maxSpeed;
		}
	}

	boolean isMoreExpensive(Car car) {
		return this.price > car.price;
	}

	void accelerate() {
		currentSpeed += 10;
		if (currentSpeed >= maxSpeed)
			currentSpeed = maxSpeed;
	}

	void changeGearUp() {
		if (currentGear == 5)
			System.out.println("No more gears to turn up!");
		else
			currentGear++;
	}

	void changeGearDown() {
		if (currentGear == 1)
			System.out.println("No more gears to turn down!");
		else
			currentGear--;
	}

	void changeGear(int gear) {
		if (gear > 0 && gear <= maxGear)
			currentGear = gear;
		else
			System.out.println("No such gear on " + model + "; Max gear = "
					+ maxGear);
	}
	
	double calculatePriceForScrap(double metalPrice)
	{
		double coef = 0.2;
		if(this.color.equalsIgnoreCase("white") || this.color.equalsIgnoreCase("black"))
			coef += 0.05;
		if(isSportsCar)
			coef += 0.05;
		return metalPrice*coef;
	}
	
	void changeOwner(Person newOwner)
	{
		this.owner = newOwner;
	}

	void printCarInfo() {
		System.out.println("=========== CAR INFO ===========");
		System.out.println("Model = " + model);
		System.out.println("Max speed = " + maxSpeed);
		System.out.println("Current Speed = " + currentSpeed);
		System.out.println("Color = " + color);
		System.out.println("CurrentGear = " + currentGear);
		System.out.println("Max gear = " + maxGear);
		System.out.println("Owner = " + owner);
		System.out.println("Price = " + price);
		System.out.println("Sports car = " + isSportsCar);
	}
}
